FROM node:20-alpine as development

WORKDIR /app

COPY package*.json ./

RUN npm config set registry https://registry.npmmirror.com/

RUN npm install --force

COPY . .

RUN npm run build

RUN echo "🎉【Server】🎉 编 🎉 译 🎉 成 🎉 功 🎉"

FROM node:20-alpine as production

ENV NODE_ENV=production

WORKDIR /app

COPY package*.json ./

RUN npm config set registry https://registry.npmmirror.com/

RUN npm i -g cross-env

RUN npm install --only=production

COPY . .

COPY --from=development /app/dist ./dist

EXPOSE 8527
EXPOSE 3000

CMD [ "npm", "run", "prod" ]